package cn.school.thoughtworks.section2;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PracticeB {
    Map<String, Integer> countSameElements(List<String> collection1) {
        Map<String,Integer> map = new HashMap<>();

        for (int i = 0; i < collection1.size(); i++) {
            if(collection1.get(i).length()>1){
                String s = collection1.get(i);
                String[] split = s.split("-");
                map.put(split[0],Integer.valueOf(split[1]));
            }else{
                if(map.containsKey(collection1.get(i))){
                    Integer integer = map.get(collection1.get(i));
                    integer+=1;
                    map.put(collection1.get(i),integer);
                }else {
                    map.put(collection1.get(i),1);
                }
            }

        }

        return map;
    }
}
